package com.freshcity.component.guide
{
	import com.freshcity.manager.support.UILayer;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	public class LineBox extends Sprite
	{
		private var _lineLays:Array;
		
		private var _lineNum:int;
		
		private var _currentNum:int;
		
		private var _refreshStep:int;
		
		private var _frameCount:int;
		
		private var _currentLine:Sprite;
		
		private var _thumbParent:Sprite;
		
		public function LineBox()
		{
			this._lineLays = [];
			this._thumbParent = new Sprite();
			this.mouseChildren = false;
			this.mouseEnabled = false;
		}
		
		public function updateLine(w:int, h:int, colors:Array, arg4:Number=5, thickness:Number=2, alpha:Number=1):void
		{
			var loc1:*=0;
			var loc3:Sprite;
			var color:*=0;
			this.dispose();
			
			this._refreshStep = arg4 * 30;
			var loc2:*=colors.length;
			while (loc1 < loc2) 
			{
				color = colors[loc1];
				(loc3 = new Sprite()).graphics.lineStyle(thickness, color, alpha);
				loc3.graphics.beginFill(0xffffff,0.01);
				loc3.graphics.drawRect(0, 0, w, h);
				loc3.graphics.endFill();
				this._lineLays.push(loc3);
				++loc1;
			}
			this._lineNum = this._lineLays.length;
			if (this._lineNum != 1) 
			{
				if (this._lineNum > 1 && this._refreshStep > 0) 
				{
					this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
				}
			}
			else 
			{
				this.addChild(this._lineLays[0]);
			}
		}
		
		private function onEnterFrame(arg1:Event):void
		{
			if (this._frameCount % this._refreshStep == 0) 
			{
				if (this._currentLine && this.contains(this._currentLine)) 
				{
					removeChild(this._currentLine);
				}
				this._currentLine = this._lineLays[this._currentNum];
				addChild(this._currentLine);
				var loc1:*;
				var loc2:*=((loc1 = this)._currentNum + 1);
				loc1._currentNum = loc2;
				if (this._currentNum == this._lineNum) 
				{
					this._frameCount = 0;
					this._currentNum = 0;
				}
			}
			loc2 = ((loc1 = this)._frameCount + 1);
			loc1._frameCount = loc2;
		}
		
		public function dispose():void
		{
			var loc1:*=null;
			if (this.parent != this._thumbParent) 
			{
				this._thumbParent.addChild(this);
			}
			this._currentNum = 0;
			this._frameCount = 0;
			this._refreshStep = 0;
			this._lineNum = 0;
			this._lineLays.splice(0);
			if (this._currentLine) 
			{
				if (this._currentLine.parent) 
				{
					removeChild(this._currentLine);
				}
				this._currentLine = null;
			}
			while (numChildren > 0) 
			{
				loc1 = this.removeChildAt(0) as Sprite;
				loc1 = null;
			}
			this.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
		}
	}
}